/*
 * @lc app=leetcode.cn id=405 lang=javascript
 *
 * [405] 数字转换为十六进制数
 */

// @lc code=start
/**
 * @param {number} num
 * @return {string}
 */
var toHex = function(num) {
    let str="0123456789abcdef"
    let s=""
    if(num==0)return '0'
    while(num){
        if(num<0){num=Math.pow(2,32)-(-num)}
        let end=num%16
        let start=parseInt(num/16)
        s=str[end]+s
        num=start
    }
    return s
};
// @lc code=end

